import result from '/@utils/Axios.ts';

export function carousel_list(params: any) {
    return result({
        url: '/api/homepage/carousels/',
        method: 'get',
        params,
    })
}

export function carousel_create(data: any) {
    return result({
        url: '/api/homepage/carousels/',
        method: 'post',
        data,
        headers: { 'Content-Type': 'multipart/form-data' }
    })
}

export function carousel_update(id: number, data: any) {
    return result({
        url: `/api/homepage/carousels/${id}/`,
        method: 'put',
        data 
    })  
}

export function carousel_delete(id: number) {
    return result({
        url: `/api/homepage/carousels/${id}/`,
        method: 'delete',
    }) 
}

export function announcement_list(params: any) {
    return result({
        url: '/api/homepage/announcements/',
        method: 'get',
        params,
    }) 
}

export function announcement_create(data: any) {
    return result({
        url: '/api/homepage/announcements/',
        method: 'post',
        data
    }) 
}

export function announcement_update(id: number, data: any) {
    return result({
        url: `/api/homepage/announcements/${id}/`,
        method: 'put',
        data
    })
}

export function announcement_delete(id: number) {
    return result({
        url: `/api/homepage/announcements/${id}/`,
        method: 'delete', 
    }) 
}

export function toggle_announcement_pin(id: number) {
    return result({
        url: `/api/homepage/announcements/toggle_pin/${id}/`,
        method: 'post',
    }) 
}

export function toggle_carousel_status(id: number) {
    return result({
        url: `/api/homepage/carousels/toggle_status/${id}/`,
        method: 'post',
    })
}

export function toggle_announcement_status(id: number) {
    return result({
        url: `/api/homepage/carousels/toggle_status/${id}/`,
        method: 'post',
    })
}

export function getData() {
    return result({
        url: `/api/homepage/data/`,
        method: 'get',
    })
}